#ifndef CHARGING_ZHONGSHENG_IO_H
#define CHARGING_ZHONGSHENG_IO_H

/**
 * @brief The charging_zhongsheng_io class
 * 中盛科技充电桩io控制模块
 * wifi 转modbustcp :4路输入4路输出 （i.0 伸出，i.1收回， o.0伸出限位， o.1收回限位）
 *
 */

#include "chargingmodel.h"
#include <QThread>

class chargingZhongSheng_IO : public ChargingModel {

public:
    explicit chargingZhongSheng_IO( QObject* parent = nullptr );
    ~chargingZhongSheng_IO();

    bool chargingOpen() override;
    bool chargingClose() override;
    bool chargingStop() override;

public slots:
    void sltTimeOut() override;

    void onTcpReadyRead() override;

private:
    uint8_t state_in[ 8 ]        = { 0x01, 0x04, 0x00, 0x00, 0x00, 0x04, 0xF1, 0xC9 };                                //读取输入通道1，通道2,通道3，通道4状态
    uint8_t state_out[ 8 ]       = { 0x01, 0x03, 0x00, 0x00, 0x00, 0x04, 0x44, 0x09 };                                //读取输出通道1，通道2,通道3，通道4状态
    uint8_t open_data[ 13 ]      = { 0x01, 0x10, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x01, 0x00, 0x00, 0xA2, 0x6F };  //打开报文写入两个输出通道：通道1开，通道2关
    uint8_t close_data[ 13 ]     = { 0x01, 0x10, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x01, 0x32, 0x6F };  //关闭报文写入两个输出通道：通道2开，通道1关
    uint8_t close_all_data[ 13 ] = { 0x01, 0x10, 0x00, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00, 0x00, 0x00, 0xF3, 0xAF };  //关闭报文写入两个输出通道：通道2开，通道1关
    bool setOut( uint8_t data[], int type );
};

#endif  // CHARGING_ZHONGSHENG_IO_H
